package com.example.wasaimovie.Config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

@Configuration
public class webMvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 映射本地文件目录
//        registry.addResourceHandler("/file")
//                .addResourceLocations("D:" + File.separator + "javaweb" + File.separator +  "IdeaProjects" + File.separator +  "WaSaiMovie" + File.separator +  "src" + File.separator
//                        + "main" + File.separator +  "resources" + File.separator +  "static" + File.separator +  "image");
        try{
            registry.addResourceHandler("/file/**")
                    .addResourceLocations("file:D:/javaweb/IdeaProjects/WaSaiMovie/src/main/resources/static/image/");
        } catch (Exception e){
            e.printStackTrace();
            System.out.println("错误映射:" + e);
        }
    }
}
